﻿@model FCNS.ERP.Models.ErpRentOrder

@{
    ViewBag.Title = "商品租赁-新增";
    Layout = "~/Views/Jxc/_Layout.cshtml";
}

<h2>@ViewBag.Title</h2>
@Scripts.Render("~/bundles/jqueryval")

<script type="text/javascript">

    $(document).ready(function () {
        $("#Rent").attr("readonly", "readonly");
        $("#Deposit").attr("readonly", "readonly");
        $("#Count").val(1);
        var r = 0;
        var d = 0;

        $("#ProductId").change(function () {
            $.get("/Basic/GetProductJsonById", {
                id: $("#ProductId").val()
            },
                function (data) {
                    r = data["Rent"];
                    d = data["Deposit"];

                    $("#Count").change();
                });
        })

        $("#Count").change(function () {
            $("#Rent").attr("value", $("#Count").val() * r);
            $("#Deposit").attr("value", $("#Count").val() * d);
        });

        $("#ProductId").change();
    });
</script>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.ProductId, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("ProductId", ViewData["Product"] as SelectList, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.ProductId, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Count, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Count, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Count, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Rent, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Rent, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Rent, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Deposit, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Deposit, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Deposit, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="新增" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink(" 返回", "Rent",null, new { @class = "backToListImg" })
</div>
